#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Stu
{
  unsigned int no;
  double a, b, c, ave, num;
  char name[25];
  struct Stu *next;
}stu;
void creat(stu *p, int n);
void prt(stu *p);

int main()
{
  stu *h;
  int n;
  while(~scanf("%d",&n))
  {
      h = (stu *)malloc(sizeof(stu));//头指针
      //h = new stu;//头指针
      h->next=NULL;
      creat(h, n);
      prt(h);
  }
  return 0;
}

void  creat(stu *p,int n)
{ 
  stu *q,*x,*y;//q创结点，x前驱，y为后驱
  int i;
  for(i=0;i<n;i++)
  {     
      x = p;
      y = p->next;
      q=(stu *)malloc(sizeof(stu));
      //q = new stu;
      scanf("%d  %s  %lf  %lf  %lf", &q->no, q->name, &q->a, &q->b, &q->c);
      q->ave = (q->a + q->b + q->c) / 3.0;
      q->num = q->a + q->b + q->c;
      while(y!=NULL && y->num > q->num)
      {
          y = y->next;
          x = x->next;
      }//找到q->num的前后驱
      x->next = q;
      q->next = y;
  }
}
void  prt(stu *p)
{
    stu *q;
    q = p->next;
      while(q!=NULL)
      {
          printf("%d  %s  %.2lf  %.2lf  %.2lf  ", q->no, q->name, q->a, q->b, q->c);
          printf("%.2lf  %.2lf\n",(q->a+q->b+q->c)/3.0,q->a+q->b+q->c);
          q = q->next;
      }
}
